Skip to content

chore: Add type stubs for Django and rest#328

Merged
berkes merged 1 commit intodevelopfrom
feature/type-stubs
Apr 8, 2026
Merged

chore: Add type stubs for Django and rest#328
berkes merged 1 commit intodevelopfrom
feature/type-stubs

Conversation

@berkes
Copy link
Copy Markdown
Contributor

@berkes berkes commented Mar 31, 2026

This "fixes" several hundreds of typing errors and warnings. Leaving us with several hundred of relevant warnings and about fifty relevant and potentially problematic errors.

Backported from feature/ewi

Add development dependencies and installation instructions

Add requirements-dev.txt with type stubs for Django and DRF Update installation docs in README, Dockerfile and
Include dev dependencies installation step in all relevant docs

@berkes berkes requested a review from ThomasKalverda March 31, 2026 08:03
@ThomasKalverda
Copy link
Copy Markdown
Contributor

This "fixes" several hundreds of typing errors and warnings. Leaving us with several hundred of relevant warnings and about fifty relevant and potentially problematic errors.

I assume you are type checking locally? I don't see the tool you are using or any readme information on how you would use these stubs. Do you also want to add 'mypy' or 'ty' to the requirements to make it complete?

@berkes
Copy link
Copy Markdown
Contributor Author

berkes commented Apr 7, 2026

I assume you are type checking locally? I don't see the tool you are using or any readme information on how you would use these stubs. Do you also want to add 'mypy' or 'ty' to the requirements to make it complete?

The reasoning for adding this was:

Yes. My nvim, as well as vscode and zed will run typecheckers on python by default. But: This PR is not to introduce typing. Nor to fix actual potential bugs found by typing.

Obv. I can disable my editor(s) from typechecking on certain projects/branches etc, but I find it highly beneficial to:

  • Ensure new code is properly type hinted
  • refactor-on-touch: when updating classes or functions, at least ensure the parts around where stuff is changed, is also typed
  • new code, changes or refactors don't introduce new typing issues.

I personally prefer basedpyright (long story); but any one is good enough.
Until the project requires a typechecker - and enforces it in CI etc etc - it can be really useful for individual developers to have to option to use type hinting and type checking when developing.

Without these stubs, typing is unusable, so we lack the option to use the IDEs typechecking, type-hinting, etc. But also, inline documentation, smart, scoped, auto-complete, "goto definition", "rename symbol" and so on (aka LSP, aka intellisense), are not avaiable in the editor, or are rather unusable on anything "Django" (models, etc)

Also, without the stubs, literally hundreds of warnings and errors that are not a problem spam the project. Hiding actual problems. This goes for any code, also new files or new classes that use Django features like models.

@berkes berkes force-pushed the feature/type-stubs branch from 5d0b7d8 to eff8b9d Compare April 7, 2026 15:13
This "fixes" several hundreds of typing errors and warnings. Leaving us
with several hundred of relevant warnings and about fifty relevant and
potentially problematic errors.

Add development dependencies and installation instructions

Add requirements-dev.txt with type stubs for Django and DRF
Update installation docs in README, dev.Dockerfile and
S3_STORAGE_SETUP.md
Include dev dependencies installation step in all relevant docs
@berkes berkes force-pushed the feature/type-stubs branch from eff8b9d to 84b5527 Compare April 8, 2026 08:43
Copy link
Copy Markdown
Contributor

@ThomasKalverda ThomasKalverda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I prefer to either support typing fully in the project or only locally, but I can see why only locally would be annoying during development (installing the stubs every time). As this is a legacy project that doesn't have to be perfect anymore, I'm fine with adding stuff like this to improve DX 👌

@berkes berkes merged commit 2a26c64 into develop Apr 8, 2026
6 checks passed
@berkes berkes deleted the feature/type-stubs branch April 8, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants